package top.scsoul.voes.examination.service.impl;

import top.scsoul.voes.examination.entity.QuestionOption;
import top.scsoul.voes.examination.mapper.QuestionOptionMapper;
import top.scsoul.voes.examination.service.QuestionOptionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (QuestionOption)表服务实现类
 *
 * @author guolei
 * @since 2021-07-23 13:11:01
 */
@Service("questionOptionService")
public class QuestionOptionServiceImpl implements QuestionOptionService {
    @Resource
    private QuestionOptionMapper questionOptionMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public QuestionOption queryById(Integer id) {
        return this.questionOptionMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<QuestionOption> queryAllByLimit(int offset, int limit) {
        return this.questionOptionMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param questionOption 实例对象
     * @return 实例对象
     */
    @Override
    public QuestionOption insert(QuestionOption questionOption) {
        this.questionOptionMapper.insert(questionOption);
        return questionOption;
    }

    /**
     * 修改数据
     *
     * @param questionOption 实例对象
     * @return 实例对象
     */
    @Override
    public QuestionOption update(QuestionOption questionOption) {
        this.questionOptionMapper.update(questionOption);
        return this.queryById(questionOption.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.questionOptionMapper.deleteById(id) > 0;
    }
}